package cn.com.headfree.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cn.com.headfree.locator.CustomRouteLocator;
import cn.com.headfree.server.service.IServerItemService;

/***
 * Title: 路由动态配置 Description:通过数据库进行动态路由配置 Copyright: Copyright (c) 2017
 * Company: www.headfree.com.cn
 * 
 * @author fengya
 * @version 1.0
 * @date 2020年1月16日 下午5:29:51
 */
@Configuration
public class ZuulConfig {

	@Autowired
	private ZuulProperties zuulProperties;
	@Autowired
	private ServerProperties server;
	@Value("redis.zuul.route.item")
	private String redisZuulRouteItem;
	@Autowired
	private IServerItemService serverItemService;

	@Bean
	public CustomRouteLocator routeLocator() {
		CustomRouteLocator routeLocator = new CustomRouteLocator(this.server.getServlet().getContextPath(),this.zuulProperties,redisZuulRouteItem,serverItemService);
		return routeLocator;
	}
}
